import java.io.IOException;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;


public class InfoCrawler {

	private String path = null;

	private String category = null;
	private String introduction = null;
	private String license = null;
	private String programmingLanguage = null;
	private String website = null;

	
	public InfoCrawler(String _path){
		path = _path;
	}
	
	public boolean run(){
		try {
			Document doc = Jsoup.connect(path).get();
			Elements elementList = null;
			
			elementList = doc.select("td:containsOwn(Categories)");
			for (Element element : elementList) {
				category = element.nextElementSibling().text();
				System.out.println("Categories: " + category);
			}
			
			elementList = doc.select("td:containsOwn(License)");
			for (Element element : elementList) {
				license = element.nextElementSibling().text();
				System.out.println("License: " + license);
			}
			
			elementList = doc.select("td:containsOwn(Programming Languages)");
			for (Element element : elementList) {
				programmingLanguage = element.nextElementSibling().text();
				System.out.println("Programming Language: " + programmingLanguage);
			}
			
			elementList = doc.select("td:containsOwn(Project Website)");
			for (Element element : elementList) {
				website = element.nextElementSibling().text();
				System.out.println("Project Website: " + website);
			}
			
			Element element = doc.select("td.body p").get(1);
			introduction = element.text();
			System.out.println("Introduction: " + introduction);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return false;
	}
}
